package com.global.college.ui.presenter;

import android.content.Context;

import com.global.college.api.ProgressSubscriber;
import com.global.college.base.BasePresenter;
import com.global.college.ui.bean.requestBean.AlipayParams;
import com.global.college.ui.interfaces.IPayOrderView;

/**
 * 支付
 */
public class PayOrderPresenter extends BasePresenter {

    private IPayOrderView mIPayView;

    public PayOrderPresenter(Context context) {
        super(context);
    }

    public void setPayView(IPayOrderView payView){
        mIPayView = payView;
    }

    /**
     * 谷歌支付消耗
     * @param
     */
    public void googlePayResume(AlipayParams params){
        // TODO: 2024/7/18 调用后端
        mAlipayRequestClient.aliPay(params).subscribe(new ProgressSubscriber<String>(mContext,true) {
            @Override
            public void onNext(String object) {
                if(null != mIPayView){
                    mIPayView.onGoogleResumeSuccess(object);
                }
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                if(null != mIPayView){
                    mIPayView.onGooglePayFail(e.getMessage());
                }
            }
        });
    }

}
